<?php

class Booking extends EMongoDocument {

    public $owner_id;
    public $active;
    public $short_id;
    public $hotel;
    public $requestDate;
    public $changeCurrency;
    public $bookingStatus;
    public $created;
    public $defaultCurrency;
    public $exchangeRates;
    public $specialRequest;
    public $airportInfo = array();
    public $flightInfo = array();
    public $guestdetails = array();
    public $matchRoom = array();
    public $contact = array();
    public $payment = array();
    public $version;
    public $new_notification;
    public $currency;
    public $cancel_notification;
    public $amend_notification;
    public $checkout;

    public function attributeLabels() {
        return array(
            'short_id' => 'Short Id',
            'owner_id' => 'Owner Id',
            'fromDate' => 'from date',
            'toDate' => 'to Date',
            'requestDate' => 'Request Date',
            'totalPayment' => 'Total Payment',
            'active' => 'active',
            'hotel' => 'Hotel',
            'bookingStatus' => 'Booking Status',
            'created' => 'Create Date',
            'defaultCurrency' => 'Default Currency',
            'exchangeRates' => 'Exchange Rates',
            'airportInfo' => 'airportInfo',
            'flightInfo' => 'flightInfo',
            'matchRoom' => 'match Room',
            'contact' => 'contact',
            'payment' => 'payment',
            'specialRequest' => 'specialRequest',
            'version' => 'version',
            'new_notification' => 'new_notification',
            'changeCurrency' => 'changeCurrency',
            'guestdetails' => 'guestdetails',
            'currency' => 'currency',
            'cancel_notification' => 'cancel_notification',
            'amend_notification' => 'amend_notification',
            'checkout' => 'checkout'
        );
    }

    public function rules() {
        return array(
            //array('specialRequest', 'required'),
            array('checkout,amend_notification,currency,guestdetails,cancel_notification,changeCurrency,new_notification,version,specialRequest,payment,contact,matchRoom,flightInfo,airportInfo,exchangeRates,created,defaultCurrency,short_id,owner_id,fromDate,toDate,requestDate,hotel,bookingStatus,totalPayment', 'safe'),
        );
    }

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function getCollectionName() {
        return 'bookings';
    }

    public function getNewNotify() {
        $criteria = new EMongoCriteria;
        $criteria->hotel = Yii::app()->session['_hotel'];
        $criteria->bookingStatus = 'confirmBooking';
        $criteria->new_notification = 1;
        $result = self::model()->findAll($criteria);
        if ($result)
            return $result;
        return array();
    }
    
    public function getCancelNotify() {
        $criteria = new EMongoCriteria;
        $criteria->hotel = Yii::app()->session['_hotel'];
        $criteria->bookingStatus = 'cancelBooking';
        $criteria->cancel_notification = 1;
        $result = self::model()->findAll($criteria);
        if ($result)
            return $result;
        return array();
    }
    
    public function getAmendNotify() {
        $criteria = new EMongoCriteria;
        $criteria->hotel = Yii::app()->session['_hotel'];
        $criteria->bookingStatus = 'amendBooking';
        $criteria->amend_notification = 1;
        $result = self::model()->findAll($criteria);
        if ($result)
            return $result;
        return array();
    }
    
    public function getAll() {
        $criteria = new EMongoCriteria;
        $criteria->sort('requestDate', EMongoCriteria::SORT_DESC);
        $criteria->hotel = Yii::app()->session['_hotel'];
        //$criteria->bookingStatus = 'confirmBooking';
        //$criteria->new_notification = 1;
        $result = self::model()->findAll($criteria);
        if ($result)
            return $result;
        return array();
    }

}

?>